{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 百度菜谱识别：适用于识别只含有单个菜品的图片，接口返回菜品的名称\n",
    "### 自己爬取的菜谱信息：来自（https://www.xinshipu.com/）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "from lxml import etree\n",
    "from urllib.parse import urljoin,quote\n",
    "import requests,base64\n",
    "#百度api\n",
    "from os import system"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这道菜的名字是驴打滚\n"
     ]
    }
   ],
   "source": [
    "# client_id 为官网获取的AK， client_secret 为官网获取的SK\n",
    "host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=nU2uq3B8rmkxhETkReNwlC07&client_secret=OeTRkbpS7Bf8SxYZE9MkGTv4I3gtOcDd'\n",
    "response = requests.get(host)\n",
    "#if response:\n",
    "#    print(response.json())\n",
    "#使用百度ai识别菜品\n",
    "request_url = 'https://aip.baidubce.com/rest/2.0/image-classify/v2/dish'\n",
    "#打开图片所在位置\n",
    "f = open('../test/food.jpg','rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "params = {\n",
    "    \"image\":img,\n",
    "    \"top_num\":5\n",
    "}\n",
    "\n",
    "access_token = '24.14339a91fe46c936c7dc5eb7ebb741c9.2592000.1611538484.282335-23393754'\n",
    "request_url = request_url + \"?access_token=\" + access_token\n",
    "headers = {'content-type':'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url,data=params,headers=headers)\n",
    "\n",
    "#if response:\n",
    "#    print(response.json())\n",
    "\n",
    "df = response.json()['result'][0][\"name\"]\n",
    "others = response.json()[]\n",
    "print(\"这道菜的名字是\"+df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------------以下是做法-----------------\n"
     ]
    }
   ],
   "source": [
    "print(\"----------------以下是做法-----------------\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1、 取糯米粉150克放入盆中，再徐徐注入150克清水，其间不停用筷子搅拌，使糯米粉均匀吸收水分；\n",
      "\t\t            \t2、 将结块的糯米粉用手团和在一起，使其成为一个完整的面团，再放入盆中稍稍压平；\n",
      "\t\t            \t3、 将盆放入蒸锅中，用大火蒸制20分钟，从蒸锅中取出放至温热；\n",
      "\t\t            \t4、 取适量椰蓉和熟芝麻备用；\n",
      "\t\t            \t5、 保鲜膜上涂上一层色拉油，放入面团，在盖上一片涂好色拉油的保鲜膜，用擀面杖将面团擀成薄片；\n",
      "\t\t            \t6、 取掉上面的保鲜膜，在面片上面均匀地铺上一层豆沙馅；\n",
      "\t\t            \t7、 从糯米皮一边卷起，直至完全卷成卷状；\n",
      "\t\t            \t8、 用刀将卷好的糯米卷从中间切成两份，其中一份裹上一层熟芝麻，另一份裹上一层椰蓉，用刀切成小段即可。\n",
      "\t\t            \t正宗的驴打滚的做法外面裹的是熟的黄豆面，用熟黄豆面做的话，可以直接在面板上铺上熟黄豆面，再放入温热的糯米面团，上面再撒上一层熟黄豆面，用擀面杖擀成薄片即可。黄豆面和涂了油的保鲜膜一样，都是起到防粘的作用。\n",
      "\t\t            \t喜欢自己做豆馅，豆香更浓也更健康，豆馅的做法见豆馅馒头。以前觉得自己做豆馅很麻烦，其实掌握以关键的几点也很简单。一是要用清水泡好放入冰箱泡一晚，熟得快；二是加足量水大火煮开，小火煮一个小时。（至于水量的多少也不一定要按以前在书上看的加三倍的水，只要加足量的水，煮一个小时后豆馅软烂了，可以把多出来的水滤出来，拌入砂糖才炒干就行了，我现在加的水量一般都刚刚合适）。在书上看到日式红豆馅的做法，还要把第一次和第二次煮红豆的水倒出去，为了去涩。不过我就一直煮，觉得豆香更浓更健康。如果想要红豆沙的话，可以用细筛网过筛，不过我喜欢吃这样的粗粗的红豆馅。想要详细做法的筒子，哪天我把书上的详细过程拍下来，可以借鉴，不过summer现在只用自己的方法，呵呵～对啦，加糖的时候可以少加一点盐，可以中和甜味，一般人我不告诉他（她）哦，呵呵～\n",
      "\t\t            \t（创建于2014-04-19）\n",
      "1:把吃剩下的白饭加上水用果汁机搅打成浓浆，米浆里加上糖在放到瓦斯炉上煮滚\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t2:煮滚后的米浆加进糯米粉搅拌揉成团即可....(糯米粉加到能成团为止)\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t3:放电锅里，外锅1杯水蒸至熟\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t4:利用耐热塑胶袋里面滴几滴的食用油搓揉一下，再把米团装进去拌揉...这个动作能让米团变得更Q...真的Q喔\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t5:把米团放在烘培纸上擀压成长方形(或是直接在塑胶袋里擀压成型)，上面均匀舖满红豆沙泥\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t6:再把它给卷起来\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t7:用黄豆粉或是花生粉当沾料...因为家里平时不用这两样，所以我把杏仁片碾碎用炒锅炒香当沾料\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t8:再卷起来外面沾满杏仁碎粒\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t9:切开后再切成块状\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t10:吃的时后直接沾著杏仁碎粒一起食用.....虽然作得不够道地，但是我发现用杏仁碎粒反而多了一层香气...真得很好吃\n",
      "                               \n",
      "                               \n",
      "\t\t\t\t\t（创建于2019-07-16）\n",
      "1: 白糯米煮熟，用一个塑胶袋裁开一个侧边，用保鲜膜或塑胶手套抓一半的白糯米饭进袋中、橄平。\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t2: 红豆馅也用同样的塑胶袋整成长条圆形(好处是长度可以和白糯米一样)\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t3: 包起来试一下大小\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t4: 塑胶袋边卷边拉开，这样完全不会沾到手，卷好后一样用原来塑胶袋包起来\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t5: 外加一层锡箔纸卷紧固定一下，如未当天食用可以直接放冷藏保存(勿超过两天)\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t6: 刀子沾水(不会沾粘)切开再滚一层黄豆粉(驴子在黄土中打滚囉)\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t7: 也可以再加黑糖蜜吃(黑糖加点水煮浓稠)\n",
      "                               \n",
      "                               \n",
      "\t\t\t\t\t（创建于2016-06-21）\n",
      "【做法】\n",
      "\t\t            \t1.提前将原料准备好，为了方便我直接买的枣泥（也可以自制红豆沙哦，我偷懒了）\n",
      "\t\t            \t2.黄豆和花生用锅炒香，个人建议用明火炒，因为会更香一些。如果不想动手的小伙伴们也可以用烤箱烤熟哦，加了少许花生的豆面会更香（秘密武器哦）\n",
      "\t\t            \t3.用适量融化白糖的温水将糯米粉调成软硬适中的面团后放入蒸锅内蒸熟，蒸的时候为了防止底部粘住，可以抹少许香油哦）\n",
      "\t\t            \t4.洗净双手，将蒸熟的面团放在底部撒有黄豆面的不粘布上用擀面擀成长方形的块，尽量薄一些长一些，中间抹上馅儿（可以根据个人口感而定）\n",
      "\t\t            \t5.从一端向另一端慢慢卷成长条状，均匀揉搓后用刀切成小馒头装即可\n",
      "\t\t            \t（创建于2017-03-20）\n",
      "1、糯米粉适量，加入温水（不烫手为宜）\n",
      "\t\t            \t2、把糯米粉揉成面团，尽量多揉几下。\n",
      "\t\t            \t3、盘里放少许植物油，为了蒸面后不粘盘，其实放了也会粘，只是效果要好些而已。\n",
      "\t\t            \t4、把面团放在盘里，摊平，入锅隔水蒸20分钟。\n",
      "\t\t            \t5、这时就可以炒黄豆粉了，把黄豆粉倒入平底锅里。\n",
      "\t\t            \t6、小火翻炒至浅棕色，有豆香味即可。\n",
      "\t\t            \t7、炒好的黄豆粉，过筛在案板上放凉。面团蒸好后取出，倒在黄豆面上。\n",
      "\t\t            \t8、面团上盖上保鲜膜，擀成薄面片。\n",
      "\t\t            \t9、在擀好的面片上抹上红豆沙。\n",
      "\t\t            \t10、从一边往里卷起，改量卷紧点。\n",
      "\t\t            \t11、卷成一条长圆条。\n",
      "\t\t            \t12、快刀切成小段就成啦！还没拍面就先吃一个，软软的糯糯的，有红豆沙的香甜，还有黄豆的豆香，一个几口就吃完了，不过糯米的东东一次不能多吃，悠着点，呵呵，拍片！\n",
      "\t\t            \t（创建于2015-04-08）\n",
      "1、所有材料调成酸奶一样的糊糊，装进微波炉用碗里，选择大火10分钟。\n",
      "\t\t            \t2、每2分钟取出用筷子搅拌一次，面团越搅拌粘性越强。\n",
      "\t\t            \t3、10分钟后取出，放到不烫手后，装进保鲜袋里卷制即可（因为加了色拉油，可以很方便的卷起来）。\n",
      "\t\t            \t（创建于2014-07-30）\n",
      "1、先来制作黄豆面。锅中无水无油，下黄豆小火翻炒。炒至淡黄色的黄豆变成均匀的浅褐色即可。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t2、炒熟的黄豆在研磨机里打磨成黄豆面。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t3、然后制作糯米皮。300g糯米粉和20g玉米淀粉放入大碗里。另取一小碗，放入20g糖和60g水，用微波炉转1分钟，取出搅拌，使之溶化为糖水。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t4、将糖水和20g油一起倒入糯米粉碗里，并分次加入剩下的水，揉成一个较软的糯米粉团。（具体加水多少要看面团状态）\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t5、将糯米粉团平摊在盘子里，裹上保鲜膜。大火上锅蒸20分钟。（摊开蒸比较容易熟）\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t6、蒸好的糯米团很粘手，放凉后就好很多。把凉后的的糯米团分成三份。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t7、取其中一份放在案板上，上面盖一层保鲜膜。（我用的是保鲜袋撕开，比保鲜膜硬一点好操作）\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t8、用擀面杖将面团擀成长方形。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t9、将保鲜膜和面片一起拎起来，翻过来放置。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t10、在糯米面片上均匀的涂上一层红豆沙，末尾处留一条白边不涂。并撒上一层黄豆面。（这里撒黄豆面只是为了增香）\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t11、把擀面杖放在保鲜膜下面向外卷，这样就可以反向推着面片向内卷起。卷的时候要用力，卷紧一些。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t12、卷好的糯米面卷，切去两头成为规则圆柱体。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t13、案板上撒上黄豆面，将面卷在上面滚动，使其均匀的裹上黄豆面，再切成小段，即成。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t14、其他外面裹什么就看由着自己发挥了。\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t15、眼花缭乱。\n",
      "\t\t            \t（创建于2015-05-17）\n",
      "1.黄豆粉放在无油无水的锅里炒香备用\n",
      "\t\t            \t2.糯米粉加适量的水揉成面团，放到保鲜袋中上锅蒸熟，蒸的时候隔几分钟要翻一翻\n",
      "\t\t            \t3.把蒸好的糯米团隔着保鲜袋用擀面仗擀平\n",
      "\t\t            \t4.把红豆沙抹在擀好的糯米团上\n",
      "\t\t            \t5.团起抹好红豆沙的糯米团\n",
      "\t\t            \t6.滚上黄豆沙或椰蓉\n",
      "\t\t            \t7.切成小段\n",
      "\t\t            \t（创建于2014-04-19）\n",
      "将大黄米面，糯米粉，糖，水混合搅拌成浓浆。烤箱预热至350 度，烤盘喷油（我是用12x17的烤盘，盘小烤得时间稍长些），将米浆倒入烤盘，入烤箱烤10—15分钟，取出稍凉后，案板上撒些黄豆粉，将烤盘倒扣，再在一片大黄米面粉团上均匀抹上豆沙，卷起后用刀切成小段，摆盘。这样，一盘好吃好看的驴打滚，就新鲜出炉啦！\n",
      "\t\t            \t（创建于2014-04-19）\n",
      "1、将糯米粉用温水和成面团，拿一个空盘子，在盘底抹一层香油，这样蒸完的面不会粘盘子。\n",
      "\t\t            \t2、将面放在盘中，上锅蒸20分钟左右。\n",
      "\t\t            \t3、翻炒黄豆面成金黄色。\n",
      "\t\t            \t4、案板上洒一层黄豆面，将放凉的糯米面擀成一个大片。\n",
      "\t\t            \t5、将红豆沙均匀抹在糯米面上卷成卷，再在最外层多撒点黄豆面。\n",
      "\t\t            \t6、用刀将糯米条切成小段（切粘面的时候在刀上沾上清水，就不会粘刀了），放在盘子里即可食用。\n",
      "\t\t            \t（创建于2017-03-30）\n",
      "1.将圆糯米洗净，泡水2∼4小时，沥干水分，再加入2杯水放入电锅内煮熟(方式与煮饭相同)。\n",
      "\t\t            \t2.糯米饭趁热用棍子捣烂，待凉后分成3份，每份各舖平成厚0.3公分的长方形片状。\n",
      "\t\t            \t3.在每片糯米饭片中间放上100公克的豆沙馅，舖平成长条形，将糯米饭片捲起成圆柱形(豆沙馅包在里面)，依序做好3份，放入冰箱冷藏1∼2小时。\n",
      "\t\t            \t4.冰凉后取出切成每段3∼4公分长的圆柱状，外表裹上熟黄豆粉，淋上黑糖蜜即可。\n",
      "\t\t            \t（创建于2013-12-30）\n",
      "1.将红枣洗净，放入热水中泡发，捞出，糯米入清水洗净，再倒入电饭锅与红枣、水(水盖过糯米的量)一起煮熟焖透\n",
      "\t\t            \t2.将黄豆粉倒入锅中以小火干炒熟，盛出备用\n",
      "\t\t            \t3.将作法1的糯米饭盛入玻璃碗中，取出红枣，加入桂花酱拌匀\n",
      "\t\t            \t4.取一干净塑料袋，放入沙拉油搓匀，将作法3倒入塑料带中揉搓成糯米团\n",
      "\t\t            \t5.将豆沙揉搓成条状备用\n",
      "\t\t            \t6.将糯米团分成3-4份，隔着塑料袋将豆沙条包入糯米团中心，再包卷成条状\n",
      "\t\t            \t7.用菜刀的反面把糯米豆沙条切成5-6公分的小段\n",
      "\t\t            \t8.将花生粉与熟黄豆粉混合拌匀，将作法7均匀地裹上花生豆粉，即为桂花驴打滚\n",
      "\t\t            \t（创建于2014-04-19）\n",
      "1、将糯米粉用冷水和成很硬的面团。然后放在铺好屉布的蒸锅上中火约蒸１５分钟。\n",
      "\t\t            \t2、黄豆面如果是熟的就在锅中干炒五分钟左右就可以了。如果是生的，就要用小火炒制约３０－４０分钟。炒制上色出锅。铺到案板上。\n",
      "\t\t            \t3、将蒸好的糯米倒在黄豆面上，趁热用沾冷开水的手把面团擀开。手要不停的沾水，否则会粘手。擀到１厘米左右的厚度就可以了。\n",
      "\t\t            \t4、把豆沙馅均匀的铺在上面（今天我用的是绿豆沙所以颜色和层次没那么好看）。然后从底部快速的卷起，也就是所谓的‘驴打滚’。\n",
      "\t\t            \t5、用刀切成块儿即可食用。\n",
      "\t\t            \t（创建于2014-04-06）\n",
      "1:糯米洗净，泡水4小时，取出沥乾，放电锅加水，水量与米平即可。\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t2:糯米饭煮好后拌入沙拉油，桂花酱，拌匀后分成二份，将一份放入耐热胶袋中，袋中先滴入少许油，用手搓揉至有黏性，但米粒没有完全糊化的程度。先推平再用擀面棍擀成薄片，可将袋子的两角剪洞，没有空气在内就可擀得很四正。\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t3:豆沙也分成两份，同样也在胶袋中擀成片，比糯米片略小一些。\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t4:先将胶袋底部剪开再从中间剪开，糯米片盖在豆沙上，然后翻转过来，使豆沙面朝上，利用塑胶袋边拉边卷，如同包寿司般卷成圆筒状，戴上手套，放在黄豆粉上沾滚后再切段。\n",
      "                               \n",
      "                               \n",
      "                               \t\t\n",
      "\t\t\t\t\t\t\t\t\t5:也可再淋上黑糖蜜一起食用，更增风味。黑糖蜜用黑糖加水煮至浓稠即可。\n",
      "                               \n",
      "                               \n",
      "\t\t\t\t\t（创建于2019-03-19）\n",
      "1混合，上锅蒸10分钟。\n",
      "\t\t            \t2取出，最好垫张保鲜膜压薄。\n",
      "\t\t            \t3挤上豆沙。\n",
      "\t\t            \t4事后感觉如果把豆沙也压平了，卷出来是不是象风车饼干那样一圈圈的。\n",
      "\t\t            \t5生的黄豆粉上锅炒，火不要大啊，一会儿就要焦的。\n",
      "\t\t            \t6撒上我就网筛了一下。\n",
      "\t\t            \t7切成段就成了。糖好象还能再加点，不甜。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\t            \t（创建于2013-03-08）\n",
      "1、所有原料秤好，备齐；\n",
      "\t\t            \t\n",
      "\t\t            \t2、干性分类混合，加入玉米油和清水，水要分次加不同品牌的糯米粉吸水量不同，先倒入大部分水，剩下30-40克分多次一点一点加；\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t3、调成这样的微微粘稠，流动畅快，滴落有花纹但会马上消失的状态；\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t4、盖上保鲜膜，上锅蒸20分钟；\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t5、翻看底部，糯米面团全部透明，没有白色液体就蒸好了；\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t6、面团趁热铲出，放在保鲜袋里擀平；\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t7、均匀的抹上豆沙馅；\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t\n",
      "\t\t            \t8、卷起来，表面撒黄豆面，切段就可以吃啦。\n",
      "\t\t            \t（创建于2016-04-04）\n",
      "1) 糯米粉，水，糖和油混合成无颗粒的面糊，微波炉高火叮2分钟，取出后搅拌，再用高火叮3分钟，至透明，待凉；\n",
      "\t\t            \t2) 红豆沙加30ml的水，搅拌均匀；\n",
      "\t\t            \t3) 案板上撒一层豆粉，把微温的糯米面团倒在上面，撒一层豆粉。擀成2mm厚的长方形片；\n",
      "\t\t            \t4) 用抹刀把红豆沙均匀抹在糯米片上，边缘处留一段不要抹。卷成卷后撒点黄豆粉；\n",
      "\t\t            \t5) 冷却后，用刀切成小段，再撒点黄豆粉。\n",
      "\t\t            \t（创建于2013-12-10）\n",
      "1.黄豆面2大勺。\n",
      "\t\t            \t2.糯米粉5大勺与黄豆面混合（可以只用糯米粉）。\n",
      "\t\t            \t3.加水调成酸奶状的面糊（水稍微多些，面糊不要太稠）。\n",
      "\t\t            \t4.面糊蒸20分钟，即蒸熟（生面糊颜色很浅，蒸熟后颜色深多了）。\n",
      "\t\t            \t5.正宗作法，此时就滚黄豆面了，但我觉得太不好操作，熟面糊特别粘，就用保鲜膜包住面团擀成长方形面片。\n",
      "\t\t            \t6.打开保鲜膜，涂上豆沙或红糖。\n",
      "\t\t            \t7.卷成一长卷，在熟黄豆面里滚一滚，再切块。\n",
      "\t\t            \t小诀窍\n",
      "\t\t            \n",
      "\t\t            我用的是买来现成的熟黄豆面，如果是生的，要事先炒熟再滚。\n",
      "\t\t\t\t\t\n",
      "\t            （创建于2013-09-22）\n",
      "1．把糯米粉、澄粉、粘米粉、糖混合，加水和成团，干湿度自己适当调节，别太干或太稀。将和好的面团用手在面板上压薄。取只大盘， 盘上抹点油，面团上盘入锅蒸10分钟。\n",
      "\t\t            \t\n",
      "\t\t            \t2．面团稍微冷却，取出。面板上撒上黄豆粉，铺上蒸好的面团，整型。最好垫张保鲜膜在面团上用擀面杖压薄。\n",
      "\t\t            \t\n",
      "\t\t            \t3．挤上豆沙，均匀铺抹好薄薄的一层，然后撒上松仁或碎核桃仁（我这次忘加了），不加也行。\n",
      "\t\t            \t\n",
      "\t\t            \t4．卷起来，切成段。以上用量掐头去尾正好做了16只小驴打滚。\n",
      "\t\t            \t（创建于2014-04-19）\n",
      "1.糯米粉中徐徐加入清水\n",
      "\t\t            \t2.加入的清水只要能揉成团即可\n",
      "\t\t            \t3.盘子上刷一层薄油，避免后面取不下来\n",
      "\t\t            \t4.入蒸锅，蒸15-20分钟。前5分钟大火，后面小火\n",
      "\t\t            \t5.取一平底锅，无油污水。倒入黄豆面小火炒熟\n",
      "\t\t            \t6.黄豆面炒制褐色即可\n",
      "\t\t            \t7.左边是没炒熟的，呈黄色。右边是炒熟的，呈褐色\n",
      "\t\t            \t8.炒好的黄豆面冷却后，筛子案板上\n",
      "\t\t            \t9.把蒸好的面皮小心的取出，放在案板上\n",
      "\t\t            \t10.在面皮上均匀的铺上一层红豆沙\n",
      "\t\t            \t11.顺着一边圈起即可\n",
      "\t\t            \t12.建议切得时候用锯齿刀，这样切得会漂亮一些\n",
      "\t\t            \t（创建于2014-04-19）\n",
      "1、黄豆面蒸20分钟并过筛备用；\n",
      "\t\t            \t2、糯米面加水混合均匀；\n",
      "\t\t            \t3、盘子上放张涂有植物油的保鲜膜（保鲜膜一定要耐热的，如果不放保鲜膜，可以盘子里面涂油也一样），再倒入糯米面糊，蒸20分钟至熟；\n",
      "\t\t            \t4、将黄豆面均匀的摊开，蒸熟的糯米面团，倒入黄豆面中摊平；\n",
      "\t\t            \t5、再将豆沙馅均匀的铺在糯米面团上，留下一厘米左右不铺，可以好卷；\n",
      "\t\t            \t6、然后将糯米面卷起。切块即可食用。\n",
      "\t\t            \t（创建于2013-07-28）\n"
     ]
    }
   ],
   "source": [
    "#爬虫返回菜谱\n",
    "BASE_URL = \"https://www.xinshipu.com/\"\n",
    "#使用菜品识别的结果\n",
    "name = df\n",
    "#name = input(\"请输入菜名：\")\n",
    "url = f\"https://www.xinshipu.com/doSearch.html?q={quote(name)}\"\n",
    "\n",
    "headers = {\n",
    "  'Authorization': 'admin eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJndWVzdCIsImV4cCI6MTYwNDY2NTI0MX0.dUAgnQFNBmO7lf5RtgNQYOvmrp-fzbpkLLZUqz_tQEdjbDDdCuT7BTV0pbS3bcdx-pDfbfpksz7Zid2IAfFJW5mapAael_J2aVZrCO7gIWOUXaWfmEmzhG0vtgSRpZa8xyy77nMVl72M3ynNAUwe25SSEM416xoOIh6c3kMJiKdkZ-oZmouDxsIfTowki4SA3TK1afVzaWq_gHyv3DbsUDV4rCvcxm359oR2xFy1xHR0OVrqv_0ExXFV0unDtLfWX4zIbQqNM9JHlKE8NTUeLfHfnY6F8C9qeEBnF0bkrigQvsOBt-TihghAFs3YF53mujE8XB7L0eiqIo-CianPztkYdjuE-W0IwddeHxOSUqKZ0C1rmhg6jSmYX7E5Y5oGeValuLKHNOhy7VlwL8vrmQOi5kH9TKYIyHT5u0u_H5R04rqccIxcdk1ghDSPvl6vMVyDTV2vxUmg8GKCcPqDjJ-giyE4rr58zJJ2fH8RXfVLHy5CokaZ67gcjNYBXf9CoXkmEJwihrxM5TPz-fS950gLQ5M2hWx1X2v8FNoLD5_v9iIvOyQuIT1PrfLFGvuxEwXXGtPaaJ9gEOEwA9QsQqruOycKArBFGVF7rclyUdfts_01TskcKvaTXVZGcT_jeDYzoDkB_Rjq3GQSLTAtopW5MOnPG4oYyz1uJ-w7Klo',\n",
    "  'Cookie': 'session=eyJ0b2tlbiI6IjMyMjE6TUVRQ0lFUWtLdS9VYStpUWRyaTQ2ZnBLWVFleVNZUm9rdVl4WFN1WFAxazBDa1RJQWlCbDVwMVhrKzdObDdBdUYrRDF0WnRKYzB5eXZYMWM4aGNRejVDMEJiQ2xJQT09In0.X6U1og.0uZAuAx2LFQrka8jUvlwOHM7F7g; JSESSIONID=F80F30BED002D6A35127AE8FEF9612F2'\n",
    "}\n",
    "\n",
    "response = requests.get(url, headers=headers, allow_redirects=False)\n",
    "next_url = urljoin(BASE_URL,response.headers['location'])\n",
    "response = requests.get(next_url, headers=headers)\n",
    "soup = etree.HTML(response.text)\n",
    "# print(next_url)\n",
    "div_list = soup.xpath('//ul[@class=\"search-list mt-12 clearfix\"]/li')\n",
    "for div in div_list:\n",
    "  try:\n",
    "    href = div.xpath('a/@href')[0]\n",
    "    innerUrl = urljoin(BASE_URL,href)\n",
    "    title = div.xpath('a/div/div/p/text()')[0]\n",
    "    img_src = div.xpath('a/div/img/@src')[0]\n",
    "    img = urljoin(BASE_URL,img_src)\n",
    "\n",
    "    # 以下是做法\n",
    "    response = requests.get(innerUrl,headers=headers)\n",
    "    zuofa_soup = etree.HTML(response.text)\n",
    "    zuofa = \"\".join(zuofa_soup.xpath('//div[@class=\"swipeboxEx mlr1 bbm\"]//text()')).strip()\n",
    "    print(zuofa)\n",
    "  except:\n",
    "    print(\"出错啦\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
